const { javaUrl, baseUrl, xxtUrl } = require("../../utils/util")

// pages/activity/activity.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone:'',
    password:'',
    active_id:'',
    user:{},
    course_info:{},
    show:0,
    choice:[],

    current: 0,  //当前所在页面的 index

    indicatorDots: true, //是否显示面板指示点

    autoplay: true, //是否自动切换

    interval: 3000, //自动切换时间间隔

    duration: 800, //滑动动画时长

    circular: true, //是否采用衔接滑动

    imgUrls: [

      'https://wechat-label.oss-cn-guangzhou.aliyuncs.com/top_img.png',

      'https://wechat-label.oss-cn-guangzhou.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20221009151414.jpg',

      'https://wechat-label.oss-cn-guangzhou.aliyuncs.com/%E5%9B%BE%E7%89%871.png'

    ],

    links: [

      '/pages/index/index',

      '/pages/index/index',

      '/pages/index/index',

    ]

  },
//轮播图的切换事件

swiperChange: function(e) {

  this.setData({

    swiperCurrent: e.detail.current

  })

},

//点击指示点切换

chuangEvent: function(e) {

  this.setData({

    swiperCurrent: e.currentTarget.id

  })

},

//点击图片触发事件

swipclick: function(e) {

  console.log(this.data.swiperCurrent);

  wx.switchTab({

    url: this.data.links[this.data.swiperCurrent]

  })

},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    this.getchoice()

    



  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  getActiveIdBut(){
    if (this.data.password=='') {
      wx.showToast({
        title: '请登陆后使用',
      })
      setTimeout(function(){
       wx.navigateTo({
         url: '/pages/xuexitong/my/my',
       })
      },1500)
    }

    wx.showLoading({
      title: '正在查询',
    })
    var that =this;
     wx.request({
       url: xxtUrl+'/activity',
       method:'POST',
       data:{
        uf:that.data.user.uf,
        _d:that.data.user._d,
        vc3:that.data.user.vc3,
        uid:that.data.user.UID,
       },
       success(res){
        if (res.data=='NoActivity') {
          wx.showToast({
            title: '没有要签到课程',
            icon:'error',
            duration:3000
          })
          return
        }  
        wx.hideLoading({
          success: (res) => {},
        })
         console.log("----"+res)
         
        that.setData({
          course_info:res.data

        })
         
      
       },
       error(e){
         console.log(e)
       }
     })
  },
  navtonewmin(){
    wx.navigateToMiniProgram({
      appId: 'wx8bb45fb9de4e888e',
      envVersion:'release',
      success(res){

      },
      fail(err){
        console.log(err)
      }
    })

  },
  signout:function(){
    wx.removeStorage({
      key: 'phone',
  
    })
    wx.removeStorage({
      key: 'pwd',
    })
   wx.navigateTo({
     url: '/pages/xuexitong/my/my',
   })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that =this
    // console.log("option",options.code)
    console.log("local",  wx.getStorageSync('login'))
   
   that.setData({
     phone:wx.getStorageSync('phone'),
     password:wx.getStorageSync('pwd'),
  
   })
   wx.request({
    
     url: xxtUrl+'/login',
     method:'POST',
     data:{
       phone:this.data.phone,
       password:this.data.password
     },
     success(res){
       console.log("denglu",res)
       wx.setStorageSync('signup', res.data)
      that.setData({
        user:res.data,
        show:1
      })
       
     }
     
   })

   wx.request({
     url: javaUrl+'/xxt/index-show/gettext',
     method:'GET',
     success(res){
       console.log("res",res)
       that.setData({
         text:res.data.data.show.indexText
       })
     }
   })
  },

  getchoice(){
    var that=this
    wx.request({
      url: javaUrl+'/xxtautosignjava/index-choice/getchoice',
      method:'GET',
      success(res){
        console.log('getchoice',res)
        that.setData({
          choice:res.data.data.choice
        })
        console.log('data ',that.data.choice)
      }
     
    })
   
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
   
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})